package com.pay.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pay.common.base.BaseService;
import com.pay.common.support.Convert;
import com.pay.mapper.auto.PayBurseMapper;
import com.pay.model.auto.PayBurse;
import com.pay.model.auto.PayBurseExample;
import com.pay.model.custom.Tablepar;
import com.pay.util.SnowflakeIdWorker;

/**
 * 支付钱包Service
 *
 * @author fuce
 * @Title: PayBurseService.java 
 * @Package com.pay.service 
 * @email 87766867@qq.com
 * @date 2019-06-24 10:54:26  
 */
@Service
public class PayBurseService implements BaseService<PayBurse, PayBurseExample> {
    @Autowired
    private PayBurseMapper payBurseMapper;

    /**
     * 分页查询
     *
     * @param tablepar
     * @return
     */
    public PageInfo<PayBurse> list(Tablepar tablepar) {
        PayBurseExample testExample = new PayBurseExample();
        testExample.setOrderByClause("id ASC");

        PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
        List<PayBurse> list = payBurseMapper.selectByExample(testExample);
        PageInfo<PayBurse> pageInfo = new PageInfo<PayBurse>(list);
        return pageInfo;
    }


    @Override
    public int deleteByPrimaryKey(String id) {
        return payBurseMapper.deleteByPrimaryKey(id);
    }

    /**
     * 添加
     */
    @Override
    public int insertSelective(PayBurse record) {
        //添加雪花主键id
        record.setId(SnowflakeIdWorker.getUUID());
        return payBurseMapper.insertSelective(record);
    }

    @Override
    public PayBurse selectByPrimaryKey(String id) {
        return payBurseMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(PayBurse record) {
        return payBurseMapper.updateByPrimaryKeySelective(record);
    }


    @Override
    public int updateByExampleSelective(PayBurse record, PayBurseExample example) {

        return payBurseMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(PayBurse record, PayBurseExample example) {

        return payBurseMapper.updateByExample(record, example);
    }

    @Override
    public List<PayBurse> selectByExample(PayBurseExample example) {

        return payBurseMapper.selectByExample(example);
    }


    @Override
    public long countByExample(PayBurseExample example) {

        return payBurseMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(PayBurseExample example) {

        return payBurseMapper.deleteByExample(example);
    }

    /**
     * 检查name
     *
     * @param payBurse
     * @return
     */
    public int checkNameUnique(PayBurse payBurse) {
        PayBurseExample example = new PayBurseExample();
        List<PayBurse> list = payBurseMapper.selectByExample(example);
        return list.size();
    }


}
